/**
 * @param {string} sequence
 * @param {string} word
 * @return {number}
 */
var maxRepeating = function (sequence, word) {
  // 暴力
  // let res = 0
  // let flag = sequence.indexOf(word) !== -1
  // let str = word
  // while (flag) {
  //   res++
  //   str += word
  //   flag = sequence.indexOf(str) !== -1
  // }
  // return res

  // 哈希
  let res = 0
  let index = sequence.indexOf(word)
  if (index == -1) {
    return res
  } else {
    for (let i = index; i < sequence.length; ) {
      if (sequence.slice(i, i + word.length) == word) {
        res++
        i += word.length
      } else {
        i++
      }
    }
  }
  return res
}



"aaaba aaab aaaba aaaba aaaba aaaba aaaba"
"aaaba"